package com.xiaojie.mapper;

import com.xiaojie.entity.UserAttempts;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName UserAttemptsMapper
 * @Description TODO
 * @Author HTGY02
 * @Date 2021/4/28 10:46
 * @Version 1.0
 **/
public interface UserAttemptsMapper {
    @Select("select * from sys_user_attempts where username=#{username}")
    UserAttempts selectByName(String username);
    /* *
     * @Author yan
     * @Description 修改重试次数
     * @Date 2021/4/28 10:53
     * @Param
     * @return
     **/
    @Update("update sys_user_attempts set attempts=#{attempts},lastModified=now() where username=#{username}")
    Integer changeRetryTimes(UserAttempts userAttempts);
    @Update("UPDATE sys_user_attempts SET attempts = 0,lastModified = null WHERE username = #{username}")
    void resetFailAttempts(String username);
    @Insert("INSERT INTO sys_user_attempts(username,attempts, lastModified) VALUES(#{username},1,now()")
    void insert(UserAttempts userAttempts);
}
